From f145a35967ee816158f1a7da70bc252542b8a746 Mon Sep 17 00:00:00 2001 From: robertlipe Date: Sun, 13 Jan 2013 23:37:20 +0000 Subject: [PATCH] Mechanical changes to build on Linux. Most were just hyper const-ipation. --This line, and those below, willignored-- M gpsbabel/jeeps/gpsusbstub.cc M gpsbabel/xcsv.cc M gpsbabel/geo.cc M gpsbabel/hsa_ndv.cc M gpsbabel/rgbcolors.cc M gpsbabel/magproto.cc M gpsbabel/gopal.cc M gpsbabel/pathaway.cc M gpsbabel/delbin.cc M gpsbabel/tef_xml.cc M gpsbabel/ozi.cc --- gpsbabel/delbin.cc | 2 +- gpsbabel/geo.cc | 8 +++++--- gpsbabel/gopal.cc | 2 +- gpsbabel/hsa_ndv.cc | 4 ++-- gpsbabel/jeeps/gpsusbstub.cc | 4 ++-- gpsbabel/magproto.cc | 6 +++--- gpsbabel/ozi.cc | 2 +- gpsbabel/pathaway.cc | 7 ++++--- gpsbabel/rgbcolors.cc | 2 +- gpsbabel/tef_xml.cc | 16 +++++++++++----- gpsbabel/xcsv.cc | 5 +++-- 11 files changed, 34 insertions(+), 24 deletions(-) diff --git a/gpsbabel/delbin.cc b/gpsbabel/delbin.cc index 16f6d4d9b..5cf76a0df 100644 --- a/gpsbabel/delbin.cc +++ b/gpsbabel/delbin.cc @@ -2947,7 +2947,7 @@ linuxhid_os_packet_write(const void* buf, unsigned size) { struct hiddev_usage_ref_multi urefm; struct hiddev_report_info rinfo; - const gbuint8* p = buf; + const gbuint8* p = (const gbuint8*) buf; unsigned i; for (i = 0; i < size; i++) { diff --git a/gpsbabel/geo.cc b/gpsbabel/geo.cc index c897613a1..a6c2d0f42 100644 --- a/gpsbabel/geo.cc +++ b/gpsbabel/geo.cc @@ -100,7 +100,7 @@ void wpt_name_s(const char* args, const char** attrv) void wpt_name(const char* args, const char** unused) { - char* s; + const char* s; if (!args) { return; } @@ -111,7 +111,9 @@ void wpt_name(const char* args, const char** unused) waypt_alloc_gc_data(wpt_tmp)->placer = xstrdup(s + 4); if (nuke_placer) { - *s = '\0'; + // Sleaze alert. We're casting away constness and writing into a string + // that should probably be read-only... + *(char *)s = '\0'; } } } @@ -155,7 +157,7 @@ void wpt_coord(const char* args, const char** attrv) void wpt_container(const char* args, const char** unused) { - int v; + geocache_container v; if (!args) { return; diff --git a/gpsbabel/gopal.cc b/gpsbabel/gopal.cc index 01fc35c8a..869ae859e 100644 --- a/gpsbabel/gopal.cc +++ b/gpsbabel/gopal.cc @@ -102,7 +102,7 @@ gopal_rd_init(const char* fname) { char buff[32]; char* ck; - char* filename; + const char* filename; CHECK_BOOL(optclean); if (optminspeed) { minspeed=atof(optminspeed); diff --git a/gpsbabel/hsa_ndv.cc b/gpsbabel/hsa_ndv.cc index 9eec3bf6f..21b9b4f71 100644 --- a/gpsbabel/hsa_ndv.cc +++ b/gpsbabel/hsa_ndv.cc @@ -211,9 +211,9 @@ hsa_ndv_read(void) static void getAttr(const char* data, const char* attr, char** val, char seperator) { - char* start; + const char* start; if ((start = strstr(data, attr)) != NULL) { - char* end; + const char* end; int len; end = strchr(start, seperator); diff --git a/gpsbabel/jeeps/gpsusbstub.cc b/gpsbabel/jeeps/gpsusbstub.cc index bf4fe7cf8..28fc39d2a 100644 --- a/gpsbabel/jeeps/gpsusbstub.cc +++ b/gpsbabel/jeeps/gpsusbstub.cc @@ -29,9 +29,9 @@ #if !HAVE_LIBUSB const char no_usb[] = "USB support is not available in this build.\n"; - +typedef struct gpsdevh gpsdevh; int -gusb_init(const char* portname) +gusb_init(const char* portname, gpsdevh** dh) { fatal(no_usb); return 0; diff --git a/gpsbabel/magproto.cc b/gpsbabel/magproto.cc index 8b2e1afa4..ae3047ed6 100644 --- a/gpsbabel/magproto.cc +++ b/gpsbabel/magproto.cc @@ -619,8 +619,8 @@ mag_dequote(char* ibuf) int nremains = strlen(esc); if (nremains >= 3) { static const char hex[17] = "0123456789ABCDEF"; - char* c1 = strchr(hex, esc[1]); - char* c2 = strchr(hex, esc[2]); + const char* c1 = strchr(hex, esc[1]); + const char* c2 = strchr(hex, esc[2]); if (c1 && c2) { int escv = (c1 - hex) * 16 + (c2 - hex); if (escv == 255) { /* corrupted data */ @@ -768,7 +768,7 @@ mag_serial_init_common(const char* portname) static void mag_rd_init_common(const char* portname) { - char* ext; + const char* ext; waypoint_read_count = 0; // For Explorist GC, intercept the device access and redirect to GPX. // We actually do the rd_init() inside read as we may have multiple diff --git a/gpsbabel/ozi.cc b/gpsbabel/ozi.cc index 449ddf75c..90632a7ce 100644 --- a/gpsbabel/ozi.cc +++ b/gpsbabel/ozi.cc @@ -162,7 +162,7 @@ void ozi_set_time_str(const char *str, waypoint *waypointp) { double ozi_time; - char *dot; + const char *dot; int len; ozi_time = atof(str); diff --git a/gpsbabel/pathaway.cc b/gpsbabel/pathaway.cc index e88b3acaa..9a4bc9142 100644 --- a/gpsbabel/pathaway.cc +++ b/gpsbabel/pathaway.cc @@ -132,10 +132,11 @@ internal_debug2(const char *format, ...) */ static -char *ppdb_strcat(char *dest, char *src, char *def, int *size) +char *ppdb_strcat(char *dest, const char *src, char *def, int *size) { int len; - char *res, *tmp; + char *res; + const char *tmp; tmp = src; if (tmp == NULL) { @@ -284,7 +285,7 @@ double ppdb_decode_coord(const char *str) CHECK_INP(1, sscanf(str,"%lf", &val), "decode_coord(1) DD.dddd", str); return val; } else { - char *tmp; + const char *tmp; if (*str == 'O') { german_release = 1; diff --git a/gpsbabel/rgbcolors.cc b/gpsbabel/rgbcolors.cc index 9e523fc96..4ad45e67d 100644 --- a/gpsbabel/rgbcolors.cc +++ b/gpsbabel/rgbcolors.cc @@ -191,7 +191,7 @@ static int HexDigit(char hex) { const char *Digits = "0123456789ABCDEF"; const char *digits = "0123456789abcdef"; - char * ofs = strchr(digits, hex); + const char *ofs = strchr(digits, hex); if (ofs) { return ofs-digits; } diff --git a/gpsbabel/tef_xml.cc b/gpsbabel/tef_xml.cc index 047788450..ab5244d82 100644 --- a/gpsbabel/tef_xml.cc +++ b/gpsbabel/tef_xml.cc @@ -161,7 +161,8 @@ tef_list_start(const char *args, const char **attrv) static char * fix_notes(const char *name, char *notes) { - char *cleft, *cright, *cback, *ctmp; + const char *cleft, *cright, *cback; + char *ctmp; if ((! name) || (! notes)) { return notes; @@ -287,19 +288,24 @@ tef_point(const char *args, const char **attrv) return; } + // FIXME: this code should really not be writing into the arg list. while (*avp) { if (strcmp(avp[0], "y") == 0) { - comma = strstr(avp[1], ","); + char *tbuf = xstrdup(avp[0]); + comma = strstr(tbuf, ","); if (comma) { *comma='.'; } - sscanf(avp[1], "%lf", &wpt_tmp->latitude); + sscanf(tbuf, "%lf", &wpt_tmp->latitude); + xfree(tbuf); } else if (strcmp(avp[0], "x") == 0) { - comma = strstr(avp[1], ","); + char *tbuf = xstrdup(avp[1]); + comma = strstr(tbuf, ","); if (comma) { *comma='.'; } - sscanf(avp[1], "%lf", &wpt_tmp->longitude); + sscanf(tbuf, "%lf", &wpt_tmp->longitude); + xfree(tbuf); } avp+=2; } diff --git a/gpsbabel/xcsv.cc b/gpsbabel/xcsv.cc index 10ff19fb2..56ccfc364 100644 --- a/gpsbabel/xcsv.cc +++ b/gpsbabel/xcsv.cc @@ -224,10 +224,11 @@ xcsv_get_char_from_constant_table(char *key) } static void -xcsv_parse_style_line(const char *sbuff) +xcsv_parse_style_line(char *sbuff) { int i, linecount = 0; - char *s, *p, *sp; + char *s, *sp; + char *p; const char *cp; char *key, *val, *pfc; -- 2.30.2